package com.larry.isn.report;

import java.util.ArrayList;
import java.util.List;

import com.larry.isn.service.IsnCalcService;
import com.pegatron.ers.server.app.helper.ContextHelper;
import com.pegatron.ers.vo.common.CommonDataModel;
import com.pegatron.ers.vo.common.MultiResultModel;

public class IsnRangeCalculator {
	private IsnCalcService isnCalcService;

	public IsnRangeCalculator() {
		isnCalcService = new IsnCalcService();
	}

	public static void main(String[] args) throws Exception {
		IsnRangeCalculator calculator = new IsnRangeCalculator();
		calculator.runCalculate();
	}

	private void runCalculate() throws Exception {
		List<CommonDataModel> datas = new ArrayList<CommonDataModel>();
		datas.addAll(this.getDatas("2013/12/20"));
		isnCalcService.summarizedISN(datas);
	}

	private List<CommonDataModel> getDateRange() throws Exception {
		MultiResultModel result = ContextHelper.getSQLStatementService().findAll(isnCalcService.getDateRange());
		return result.getDatas();
	}

	private List<CommonDataModel> getDatas(String date) throws Exception {
		MultiResultModel result = ContextHelper.getSQLStatementService().findAll(isnCalcService.getSql(date));
		return result.getDatas();
	}
}
